<template>
  <DataList 
  :cate="cate" 
  :cols="cols" 
  :name="name"
  :excelHeader="excelHeader"
  skipExcelNumber="3"
  />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import linq from "linq"
import { addJydw, deleteJydw, updateJydw, getJydw,bulkAddJydw} from "@/api/社会评价.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A9-4应届毕业生主要就业单位与联系人表",
      name:"9.4 就业单位与联系人",
      excelHeader:{B3:"应届毕业生主要就业单位名称(全称)",C3:"是否做过雇主调查",D3:"就业单位联系人信息",D4:"姓名",E4:"职务",F4:"区号－电话号码",G4:"电子邮箱"},
      cols: [
        { prop: "JYDW", label: "应届毕业生主要就业单位名称 (全称)" },
        { prop: "XZ_SFGZDC", label: "是否做过雇主调查" },
        { prop: "就业单位联系人信息", label: "就业单位联系人信息",
          data:[
            { prop: "XM", label: "就业单位联系人信息_姓名" },
            { prop: "ZW", label: "就业单位联系人信息_职务" },
            { prop: "LXDH", label: "就业单位联系人信息_区号_电话号码" },
            { label: "电子邮箱", prop: "DZYX" },
          ] 
        }
      ]
    };
  },
  methods: {
    getSummaries(list){
      const sums = []
         this.cols.forEach((column, index) => {
            sums[index]=""
        })
        sums[0]="合计";
        sums[6]= "单位数:"+linq.from(list).count("$.JYDW")
        sums[7]= "做过调查:"+linq.from(list).count("$.XZ_SFGZDC")
        sums[12]= "通过:"+linq.from(list).where("$.审核状态=='通过'").count()
        sums[12] += ",待审核:"+linq.from(list).where("$.审核状态=='待审核'").count()
        sums[12]+= ",不通过:"+linq.from(list).where("$.审核状态=='不通过'").count()
        return sums;
    },
    check(array,list) {
     return new Promise(async (resolve,reject)=>{
       resolve();
     })},
    // async fetchData() {
    //   var user = getUser();
    //   var datas = await getJydw(user.XXID,user.CJPC);
    //   return datas;
    // },
    onadd(model) {
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
         
        console.log(JSON.stringify(temp));
        var model = await addJydw(temp);
        resolve(model);
      })
    },
    async bulkAdd(array){
      await bulkAddJydw({Xsjy:array});
    },
    onupdate(model) {
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateJydw(temp);
          resolve(model);
      })
    },
    ondelete(model) {
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
      
      await deleteJydw(temp);
      resolve();
      })
    }
  }
};
</script>
<style>
</style>